package SecondeStage.Networkprogramming.UDPFileUpload;

import java.io.IOException;
import java.net.*;

public class UDPSenderB {
    public static void main(String[] args) throws IOException {
        // 1. 创建一个 DatagramSocket对象，准备在9998接收数据
        DatagramSocket socket =new DatagramSocket(9998);
        // 2. 将需要发送的数据，封装到DatagramPacket对象中
        byte[] data = "hello 明天吃火锅".getBytes();
        // 封装的 DatagramPacket对象(data内容字节数组，data.length,主机IP,端口)
        DatagramPacket datagramPacket=new DatagramPacket(data, data.length,InetAddress.getByName("10.20.225.19"),9999);
        socket.send(datagramPacket);
        // 3. 关闭资源
        socket.close();
        System.out.println("B端退出");
    }
}
